package com.heima.day528_二维数组;

public class TwodArray2 {


    public static void main(String[] args) {
        int[][] arr = {{22, 66, 44}, {77, 33, 88}, {25, 45, 65}, {11, 66, 99}};
       /* int[] jd1 = {22, 66, 44};
        int[] jd2 = {77, 33, 88};
        int[] jd3 = {25, 45, 65};
        int[] jd4 = {11, 66, 99};*/
        // System.out.println(arr[2][2]);
        Qsum(arr);
        System.out.println("所有季度最高销售额为： " + Qmax(arr));
    }

    //所有季度销售额求和
    public static void Qsum(int[][] arr) {
        //定义和变量
        int sum = 0;
        //遍历二维数组
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[2].length; j++) {
                //  System.out.print(arr[i][j]);
                sum += arr[i][j];
            }
        }
        System.out.println("所有季度和为： " + sum);
    }

    //所有季度最高销售额
    public static int Qmax(int[][] arr) {
        //定义最大值变量max
        int max = 0;
        //for循环遍历二维数组
        for (int i = 0; i < arr.length; i++) {
            //for循环遍历一维数组
            for (int j = 0; j < arr[i].length; j++) {
                //if判断最大值
                if (max < arr[i][j]) {
                    max = arr[i][j];
                }
            }
        }
        return max;
    }


}
